package com.company.OfferGuide;

public class 调整数组顺序使奇数位于偶数前面 {

    public int[] exchange(int[] nums) {
        int[] ints = new int[nums.length];

        int k = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] % 2 == 1) {
                ints[k++] = nums[i];
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] % 2 == 0) {
                ints[k++] = nums[i];
            }
        }

        return ints;
    }

}
